Skip to content

Comments

fix: carry request.cf through debug port capnp layer#6116

Merged
penalosa merged 1 commit intomainfrom
penalosa/debug-port-cf-blob
Feb 20, 2026
Merged

fix: carry request.cf through debug port capnp layer#6116
penalosa merged 1 commit intomainfrom
penalosa/debug-port-cf-blob

Conversation

@penalosa
Copy link
Contributor

Summary

  • Fixes request.cf being lost when requests go through the debug port (used by Miniflare's native dev registry for cross-worker service bindings)
  • The cf blob was already being passed to startRequest(metadata) by Fetcher::getClientWithTracing() but WorkerdBootstrapSubrequestChannel ignored it entirely

Changes

Sender side (workerd-debug-port-client.c++):

  • CfInjectingWorkerInterface: thin WorkerInterface wrapper that injects MF-CF-Blob header into outgoing HTTP requests when metadata.cfBlobJson is present
  • WorkerdBootstrapSubrequestChannel::startRequest() now wraps the RpcWorkerInterface with CfInjectingWorkerInterface when cf blob is provided

Receiver side (server.c++):

  • CfAwareHttpService: wraps the target service's HTTP interface, extracts MF-CF-Blob header from incoming requests, and passes cf to SubrequestMetadata
  • EventDispatcherImpl defers WorkerInterface creation until the HTTP request arrives (stores SubrequestChannel instead of WorkerInterface), enabling cf blob extraction
  • startEvent() passes kj::addRef(*service) instead of service->startRequest({})

Context

Part of cloudflare/workers-sdk#12600 — refactoring the Miniflare dev registry to use native debug port RPC instead of a Node.js HTTP proxy.

@penalosa penalosa force-pushed the penalosa/debug-port-cf-blob branch 3 times, most recently from 8e0854b to 3176119 Compare February 20, 2026 11:51
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 20, 2026

Merging this PR will degrade performance by 95.18%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 68 untouched benchmarks
⏩ 129 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
simpleStringBody[Response] 20.2 µs 419.6 µs -95.18%
bodyWithHeaders[Response] 39.5 µs 30.3 µs +30.64%

Comparing penalosa/debug-port-cf-blob (5b261bd) with main (c4d649b)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@penalosa penalosa force-pushed the penalosa/debug-port-cf-blob branch from 3176119 to 5e2b2ad Compare February 20, 2026 16:59
@penalosa penalosa marked this pull request as ready for review February 20, 2026 17:00
@penalosa penalosa requested review from a team as code owners February 20, 2026 17:00
Add cfBlobJson as a parameter to WorkerdBootstrap::startEvent() in the capnp
schema, so request.cf travels as a first-class RPC value through the debug port.

Sender (workerd-debug-port-client.c++):
- startRequest() passes metadata.cfBlobJson via req.setCfBlobJson() on startEvent

Receiver (server.c++):
- startEvent() extracts cfBlobJson from RPC params, passes to EventDispatcherImpl
- getHttpService() includes cfBlobJson in SubrequestMetadata when creating WorkerInterface
- EventDispatcherImpl defers WorkerInterface creation (stores SubrequestChannel)
@penalosa penalosa force-pushed the penalosa/debug-port-cf-blob branch from 5e2b2ad to 5b261bd Compare February 20, 2026 19:52
@penalosa penalosa merged commit 02c8669 into main Feb 20, 2026
22 checks passed
@penalosa penalosa deleted the penalosa/debug-port-cf-blob branch February 20, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants